package com.xuecheng.content.api;

import com.xuecheng.base.exception.ResponseResult;
import com.xuecheng.content.model.dto.*;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(value ="教学计划",tags = "教学计划管理接口")
public class TeachPlanController {
    @Autowired
    private TeachplanService teachplanService;

    @ApiOperation("查询教学计划")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachplanTreeNodeDto> selectTreeNode(@PathVariable Long courseId){

        return teachplanService.selectTeachTreeNodes(courseId);
    }
    @ApiOperation("新增章节")
    @PostMapping("/teachplan")
    public TeachplanDto createTeachPlan(@RequestBody SaveTeachplanDto saveTeachplanDto){
        return teachplanService.createChapter(saveTeachplanDto);
    }

    @ApiOperation("删除课程计划")
    @DeleteMapping("/teachplan/{teachplanId}")
    public ResponseResult deleteTeachplan(@PathVariable("teachplanId") Long teachplanId){
        return teachplanService.deleteChapter(teachplanId);
    }

    @ApiOperation("章节移动")
    @PostMapping("/teachplan/{type}/{teachplanId}")
    public void teachplanMoveDownOrUp(@PathVariable("teachplanId") Long teachplanId,@PathVariable("type") String type){
        teachplanService.teachplanMoveDownOrUp(teachplanId,type);
    }

    @ApiOperation("查询教学计划资源文件信息")
    @PostMapping("/teachplan/media/{teacherId}")
    public TeachplanAndTeachplanMediaDto teachplanAndTeachplanMedia(@PathVariable("teacherId") Long teacherId){
        return teachplanService.teachplanAndTeachplanMedia(teacherId);
    }

    @ApiOperation("课程大纲添加文件")
    @PostMapping("/teachplan/mediaAdd")
    public TeachplanAndTeachplanMediaDto teachplanMediaUpdateFile(@RequestBody MediaFilesDto mediaFilesDto){
        return teachplanService.teachplanMediaUpdateFile(mediaFilesDto);
    }
}
